package com.lyc.service.impl;

import java.util.List;

import com.lyc.dao.MedalInfoDAO;
import com.lyc.dao.imp.MedalInfoDAOImpl;
import com.lyc.dto.MedalDto;
import com.lyc.dto.MedalSearch;
import com.lyc.dto.PageDTO;
import com.lyc.service.MedalService;

public class MedalServiceImpl implements MedalService {

	private MedalInfoDAO dao = new MedalInfoDAOImpl();
	
	@Override
	public List<MedalDto> list(MedalSearch search) {
		try {
			return dao.selectSearch(search);
		}catch(Exception e) {
			throw new RuntimeException("获取奖牌列表失败",e);
		}
	}

	@Override
	public PageDTO<MedalDto> page(MedalSearch search) {
		try {
			PageDTO<MedalDto> p = new PageDTO<MedalDto>(dao.countSearch(search), search.getCurrent(), search.getRowMax());
			search.setCurrent(p.getCurrent());
			p.setList(dao.selectSearch(search));
			return p;	
		}catch(Exception e) {
			throw new RuntimeException("获取奖牌分页失败",e);
		}
	}

}
